<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ include file="/WEB-INF/jspf/jsDefault.jspf" %>


<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.mail.internet.*,javax.activation.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%
   String result;
   // Recipient's email ID needs to be mentioned.
   String to = "abcd@gmail.com";

   // Sender's email ID needs to be mentioned
   String from = "mcmohd@gmail.com";

   // Assuming you are sending email from localhost
   String host = "localhost";

   // Get system properties object
   Properties properties = System.getProperties();

   // Setup mail server
   properties.setProperty("mail.smtp.host", host);

   // Get the default Session object.
   Session mailSession = Session.getDefaultInstance(properties);

   try{
      // Create a default MimeMessage object.
      MimeMessage message = new MimeMessage(mailSession);
      // Set From: header field of the header.
      message.setFrom(new InternetAddress(from));
      // Set To: header field of the header.
      message.addRecipient(Message.RecipientType.TO,
                               new InternetAddress(to));
      // Set Subject: header field
      message.setSubject("This is the Subject Line!");
      // Now set the actual message
      message.setText("This is actual message");
      // Send message
      Transport.send(message);
      result = "Sent message successfully....";
   }catch (MessagingException mex) {
      mex.printStackTrace();
      result = "Error: unable to send message....";
   }
%>




<f:view>
    <html>
        <head>
            <%@ include file="/WEB-INF/jspf/header.jspf" %>
        </head>
        <body>
            <%@ include file="/WEB-INF/jspf/controlloAmministratore.jspf" %>
            <div id="main">
                <header>
                    <div id="logo">
                        <%@ include file="/WEB-INF/jspf/logoContent.jspf" %>
                    </div>
                    <nav id="barraMenu">
                        <div id="menu_container">
                            <ul class="sf-menu" id="nav">
                                <h:form>
                                    <li ><a href="javascript:void(0)">Home</a></li>
                                    <li class="due"><h:commandLink action="recStudente.jsp">Iscrizione</h:commandLink></li>
                                    <li class="tre"><h:commandLink action="sedi.jsp">Sedi</h:commandLink></li>
                                    <li class="quattro"><h:commandLink action="cercaArticolo.jsp">Articoli</h:commandLink></li>
                                    <li class="cinque"><h:commandLink action="file.jsp">File</h:commandLink></li>
                                         <li><a href="javascript:mostraDialog()">About</a></li>
                                    </h:form>
                            </ul>
                        </div>
                    </nav>
                </header>
                <div id="site_content">
                    <div id="sidebar_container">
                        <%@ include file="/WEB-INF/jspf/loggedForm.jspf" %>
                    </div>
                    <div class="content">
                        <!-- 
                        
                        
                        
                        INSERIRE QUI IL CONTENUTO DELLA PAGINA 
                        
                        
                        
                        -->




                        <center>
                            <h1>Send Email using JSP</h1>
                        </center>
                        <p align="center">
                            <% 
                               out.println("Result: " + result + "\n");
                            %>
                        </p>






                    </div>
                </div>
                <footer>
                    <p>Copyright &copy; FF-RL 2014</p>
                </footer>
            </div>
            <p>&nbsp;</p>
            <%@ include file="/WEB-INF/jspf/about/contatti.jspf" %>
        </body>
    </html>
</f:view>
